//定义reducer初始中
import {
    INCREMENTCOUNT,
    DECREMENTCOUNT
  } from '../constant/countConst'

 const init ={
    count:0
 }
 export default function countReducer(prevStata =init, action){
    const {
        type,
        data
    } = action
    //做判断
    switch(type){
        case INCREMENTCOUNT:
            return {
                ...init ,count:prevStata.count+data
            };

        case DECREMENTCOUNT:
            return {
                ...init ,count:prevStata.count-data
            };
        
    }
    console.log('reducer被调用了');
    return prevStata;
 }